/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImageDisplay.java
 *
 * Created on May 12, 2013, 5:12:23 PM
 */

package democarmanagement;

import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author Minhdaica
 */
public class ImageDisplay extends javax.swing.JFrame {

    /** Creates new form ImageDisplay */
    public ImageDisplay() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jImageScollDisplay = new javax.swing.JScrollPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jImageScollDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 606, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jImageScollDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ImageDisplay().setVisible(true);
            }
        });
    }
    public void displayImage(String path,File[] file) {
        try {
            BufferedImage image;
            image = ImageIO.read(new File(path));

            JPanel panel = new JPanel(new GridLayout(file.length, 1));
            JLabel lable = new JLabel(new ImageIcon(image));
            panel.add(lable);

            jImageScollDisplay.setViewportView(panel);

        } catch (IOException ex) {
            Logger.getLogger(ImageDisplay.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public JScrollPane getJImageScollDisplay() {
        return jImageScollDisplay;
    }

    public void setJImageScollDisplay(JScrollPane jImageScollDisplay) {
        this.jImageScollDisplay = jImageScollDisplay;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jImageScollDisplay;
    // End of variables declaration//GEN-END:variables

}
